# 5.2.1字典元素添加修改
# 1.添加字典元素
add_dict = {'stu1':'小明'}
add_dict.update(stu2='小刚')
add_dict['stu3'] = '小兰'
print(add_dict)

# 2.修改字典元素
modify_dict = {'stu1': '小明', 'stu2': '小刚', 'stu3': '小兰'}
modify_dict.update(stu2='小强')
modify_dict['stu3'] = '小婷'
print(modify_dict)

# 5.2.2字典元素的删除
# 1.pop()
per_info = {'001':'张三','002':'李四','003':'王五','004':'赵六',}
print(per_info.pop('001'))
print(per_info)

# 2.popitem()
per_info = {'001':'张三','002':'李四','003':'王五','004':'赵六',}
print(per_info.popitem())
print(per_info)

# 3.clear()方法
per_info = {'001':'张三','002':'李四','003':'王五','004':'赵六',}
print(per_info.clear())
print(per_info)

# 5.2.3字典元素的查询
per_info = {'001':'张三','002':'李四','003':'王五','004':'赵六',}
# 1.查询字典的所有元素/items()
print(per_info.items())

per_info = {'001':'张三','002':'李四','003':'王五','004':'赵六',}
for i in per_info.items():
    print(i)
# 2.查询字典的所有键/keys()
print(per_info.keys())
# 3.查询字典的所有值/values()
print(per_info.values())

per_info = {'001':'张三','002':'李四','003':'王五','004':'赵六',}
for i in per_info.values():
    print(i)